package com.csti.delio.main.server.login;

import java.util.List;

import com.csti.delio.main.client.login.UsService;
import com.csti.delio.main.client.login.Usuario;
import com.csti.delio.main.server.Conexion;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.ibatis.sqlmap.client.SqlMapClient;

public class UsServiceImpl extends RemoteServiceServlet implements UsService{

	Conexion con;
    SqlMapClient sqlMap;
    
	public UsServiceImpl(){
		con  = new Conexion();
		sqlMap = con.getSqlMap();
	}

	
	@Override
	public boolean validar(Usuario us) {
        boolean var = false;
        Integer id=0;
        System.out.println("entro en validarrrrrrrrrrrrrrrrrrrr");
        try{
        	System.out.println("entro en validarrrrrrrrrrrrrrrrrr");
        	id = (Integer)sqlMap.queryForObject("ValidarUsuario",us);
        	if(id==0)var=false;
        	if(id==1)var=true;
        }catch(Exception e){
        	e.printStackTrace();
        }
		return var;
	}

	@Override
	public List<Usuario> ListarUs() {
		List<Usuario> lu = null;
		try{
			lu = sqlMap.queryForList("ListarUsuario");
		}catch(Exception e){
			e.printStackTrace();
		}
		return lu;
	}
}
